#include "File.h"

bool File::OpenRead(const std::string& filename)
{
	m_file.open(filename.c_str());

	return m_file.good();
}


bool File::GetString(std::string *pStringResult)
{
	if (!m_file.good())
	{
		return false;
	}
	while(true)
	{
		const int MAX_BUF_SIZE = 1000;
		char buf[1000];
		m_file.getline(buf, MAX_BUF_SIZE);
		if (buf[0] == '/' || buf[0] == 0)
		{
			continue;
		}

		*pStringResult = buf;

		return true;
	}
}

bool File::GetInteger(int *pIntResult)
{
	std::string s;
	GetString(&s);
	*pIntResult = atoi(s.c_str());
	return true;
}

bool File::GetFloat(float *pFloatResult)
{
	std::string s;
	GetString(&s);
	*pFloatResult = atof(s.c_str());
	return true;
}